package cn.dm.example.threadLocal;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/threadLocal")
public class ThreadLocalController {

    /**
     * 访问 http://localhost:8081/threadLocal/test
     * <p>
     * 网页出现 42
     * <p>
     * 控制台打印如下日志信息
     * 2022-06-11 09:14:33.862  INFO 7928 --- [nio-8081-exec-1] cn.dm.HttpFilter      : do filter, 42, /threadLocal/test
     * 2022-06-11 09:14:33.870  INFO 7928 --- [nio-8081-exec-1] cn.dm.HttpInterceptor : preHandle
     * 2022-06-11 09:14:33.902  INFO 7928 --- [nio-8081-exec-1] cn.dm.HttpInterceptor : afterCompletion
     */
    @RequestMapping("/test")
    public Long test() {
        return RequestHolder.getId();
    }
}
